<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" href="#" type="../image/png">
  <title>Demo</title>
  <!--data table-->
  <link rel="stylesheet" href="../js/data-tables/DT_bootstrap.css" />


</head>
<body class="sticky-header" onload="indexmenu('${oneMenu}','${twoMenu}');">
<%@ include file="../index/index.jsp" %>
<section>
	<div class="main-content">

        <!-- 地址栏-->
		<div class="page-heading">
            <h3>
                	后台管理系统
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">消息管理</a>
                </li>
                <li class="active">顾客消息</li>
            </ul>
        </div>   
		<!--这里是写一些内容的  -->
		<div class="row">
	        <div class="col-sm-12">
	        	<section class="panel">
		        	<div class="panel-body">
		        		<div class="adv-table">
		      				<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline" role="grid">
		        				<button class="btn btn-success" type="button" onclick="addGoods()" data-toggle="modal" data-target="#addMessage">新增消息</button>
		        				<div class="span6">
		        					<h4>顾客消息列表:</h4>
		        					<div class="dataTables_filter" id="dynamic-table_filter">
							        	<input type="text" class="form-control" placeholder="搜索消息" aria-controls="dynamic-table" id="search">
							        	<button  class="btn btn-default" type="button" onclick="screahCustomerMessage(1)">搜索</button>
		  							</div>
		       		 			</div>
		       				</div>
		       				
		       				<!--表格开始  -->
			       			<table class="display table table-bordered table-striped dataTable table-hover" id="dynamic-table" aria-describedby="dynamic-table_info">
			        			<thead>
						        	<tr role="row">
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 80px;" aria-label="Rendering engine: activate to sort column ascending">消息id</th>						        	
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">消息内容</th>
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">生成时间</th>
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">是否已推送</th>						        							        		
						        		<th class="sorting" role="columnheader" tabindex="0" aria-controls="dynamic-table" rowspan="1" colspan="1" style="width: 100px;" aria-label="Rendering engine: activate to sort column ascending">编辑</th>
						        	</tr>
						        </thead>
							    <tbody role="alert" aria-live="polite" aria-relevant="all">
							    	<c:forEach var="message" items="${messages}">
							        	<tr class="gradeA even" >
							           		<td class="">${message.messageId}</td>			           				
								            <td class="">${message.content}</td>
								            <td class="">${message.addTimes}</td>
								            <c:choose>  
   												<c:when test="${message.status==1}">    <!--如果 --> 
   													<td class="">是</td>		
    											</c:when>  
    											<c:otherwise>  <!--否则 -->  
    												<td class="">否</td>	
    											</c:otherwise>  
 											</c:choose>
								          	<td class="">
								          		<button class="btn btn-info" type="button" data-toggle="modal" data-target="#myModal" onclick="clickMessage(${message.messageId})">修改</button>	
								          		<button class="btn btn-danger" type="button" onclick="toDeleteMessage(${message.messageId})">删除</button>		      
								          	</td>						            
								        </tr>							    		
							    	</c:forEach>
							  	</tbody>
							</table>
							<!-- 表格结束 -->
							<!-- 分页开始 -->
						  	<div class="row-fluid">
							  	<div class="span6">
								  	<div class="dataTables_paginate paging_bootstrap pagination">
									  	<ul>									  		
								  			<c:choose>
									  			<c:when test="${page.currentPage==1}">
									  				<li class="prev">
									  					<a class="page-link">← 上一页</a>
									  				</li>
									  			</c:when>
									  			<c:otherwise>
									  				<li class="prev">
									  					<a href="../message/customerMessage.do?currentPage=${page.currentPage-1}" class="page-link">← 上一页</a>
									  				</li>
									  			</c:otherwise>	 							  			
								  			</c:choose>
						                  <c:forEach begin="1" end="${page.totalPage}" var="p">
						                    	<c:choose>
						                    		<c:when test="${page.currentPage==p}">
						                    			<c:if test="${p==1}">
						                    				<li  class="active page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p}" class="page-link">${p}</a></li> 
						                    				<c:if test="${page.totalPage>1}">
						                    					<li  class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p+1}">${p+1}</a></li>
						                    				</c:if>
						                    				<c:if test="${page.totalPage>2}">
						                    					<li  class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p+2}">${p+2}</a></li>
						                    				</c:if>
						                    				<c:if test="${page.totalPage>3}">
							                    				<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    			</c:if>
						                    			</c:if>
						                    			<c:if test="${p>1}">                   			                   			
							                    			<c:if test="${p<page.totalPage}">
							                    				<c:if test="${p>2}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    				<li class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p-1}">${p-1}</a></li>
							                    				<li class="active page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p}" class="current_page">${p}</a></li>
							                    				<c:if test="${page.totalPage>2}">
							                    					<li class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p+1}">${p+1}</a></li>
							                    				</c:if>
							                    				<c:if test="${page.totalPage-p>1}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    			</c:if>
							                    			<c:if test="${p==page.totalPage}">
							                    				<c:if test="${p>3}">
							                    					<li class="page-item"><a class="page-link" href="#">...</a></li>
							                    				</c:if>
							                    				<c:if test="${p>2}">
							                    					<li class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p-2}">${p-2}</a></li>
							                    				</c:if>
							                    				<li class="page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p-1}">${p-1}</a></li>
							                    				<li class="active page-item"><a class="page-link" href="../message/customerMessage.do?currentPage=${p}" class="current_page">${p}</a></li>
							                    			</c:if>
						                    			</c:if>
						                    		</c:when>
						                    	</c:choose>
						                    </c:forEach>					

								  			<c:choose>
									  			<c:when test="${page.currentPage==page.totalPage}">
									  					<li class="pre"><a class="page-link">下一页 → </a></li>
									  			</c:when>
									  			<c:otherwise>
									  					<li class="pre"><a href="../message/customerMessage.do?currentPage=${page.currentPage+1}" class="page-link">← 下一页</a>
									  					</li>
									  			</c:otherwise>	 							  			
								  			</c:choose>
											<li class="page-item"> <a class="page-link">总共${page.totalPage}页</a></li>
									  	</ul>
								  	</div>
								</div>
							</div>
							<!-- 分页结束 -->
						</div>
						
					</div>
        		</section>
        	</div>
       </div>		
       <!-- 查看详情的模态框 -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		        <h4 class="modal-title" id="myModalLabel">修改活动</h4>
		      </div>
		      <div class="modal-body">
		       <!--这是模态框内容  -->
		       
				<form id="messageX" class="form-horizontal" role="form">
				  <div id="messageName" class="form-group">
				  	<!-- 活动id和活动状态 -->
				  	<input type="hidden" id="messageId" name="messageId">
				    <label  class="col-sm-2 control-label">活动名称</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" placeholder="活动名称" name="content">
				    </div>
				  </div>
				  <div class="form-group">
				    <label  class="col-sm-2 control-label">消息推送</label>
				  </div>
				  <div id="messageStatus" style="position: relative; margin-left: 259px;">
					<div class="radio">
					  <label>
					    <input type="radio" name="status" id="openStatus" value="1">
					    	是
					  </label>
					</div>
					<div class="radio">
					  <label>					<!--  optionsRadios-->
					    <input type="radio" name="status" id="closeStatus" value="0">
					    	否
					  </label>
					</div>				  
				  </div>
				 	<div id="messageType" class="form-group">
				    <label  class="col-sm-2 control-label">消息类型</label>
				    <div class="col-sm-10">
				      <input type="radio" name="type" value="0" checked="checked">
				      	顾客
				    </div>
				   </div>	
				</form>
		       
		       <!-- 这是模态框内容结束 -->
		      </div>
		      <div class="modal-footer">    <!-- 按钮黑色 btn-primary -->
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		        <button type="button" class="btn btn-default" data-dismiss="modal" onclick="saveMessage()">保存</button>
		      </div>
		    </div>
		  </div>
		</div> 
       <!-- 增加新活动模态框 -->
		<div class="modal fade" id="addMessage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		        <h4 class="modal-title" id="myModalLabel">增加新消息</h4>
		      </div>
		      <div class="modal-body">
		       <!--这是模态框内容  -->
				<form id="addMessageII" class="form-horizontal" role="form">
				  <div id="messageName" class="form-group">
				    <label  class="col-sm-2 control-label">消息内容</label>
				    <div class="col-sm-10">
				      <input type="text" class="form-control" placeholder="消息内容" id="" name="content">
				    </div>
				   </div>	
				    <div class="form-group">
				    	<label  class="col-sm-2 control-label">直接推送</label>
				    </div>
				  <div id="messageStatus" style=" position: relative; margin-left: 259px;">
					<div class="radio">
					  <label>
					    <input type="radio" name="status" id="openStatus" value="1" checked="checked">
					    	是
					  </label>
					</div>
					<div class="radio">
					  <label>					<!--  optionsRadios-->
					    <input type="radio" name="status" id="closeStatus" value="0">
					    	否
					  </label>
				  </div>
				</div>
				<div id="messageType" class="form-group">
				    <label  class="col-sm-2 control-label">消息类型</label>
				    <div class="col-sm-10">
				      <input type="radio" name="type" value="0" checked="checked">
				      	顾客
				    </div>
				   </div>	
				</form>
		       
		       <!-- 这是模态框内容结束 -->
		      </div>
		      <div class="modal-footer">    <!-- 按钮黑色 btn-primary -->
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		        <button type="button" class="btn btn-default" data-dismiss="modal" onclick="addMessage()">保存</button>
		      </div>
		    </div>
		  </div>
		</div> 		
		<!--内容结束  -->
	</div>
</section>

</body>
<script src="../js/message/addMessage.js"></script>
</html>
